#-*- coding:utf-8 –*-

import pandas as pd
from pandas import Series,DataFrame

data = {
	"id":["1", "2", "3"],
	"name":["张三", "李四", "王五"],
	"age":[27, 30, 21]
}
df1 = DataFrame(data, columns=["id", "name", "age", "date"])
print df1

print "字典套字典的方法".decode('utf-8').encode('cp936')

data = {
	"id":{0:"1", 1:"2", 2:"3", 3:"4"},
	"name":{0:"张三", 1:"李四", 2:"王五"},
	"age":{0:27, 1:30, 2:21, 3:50}
}
df2 = DataFrame(data, columns=["id", "name", "age", "date"])
print df2

print "获取姓名列表(可以将 DataFrame 理解为是有一个一个的 Series 组成的)".decode('utf-8').encode('cp936')
print df2["name"]
print "给没有数值的一列赋值".decode('utf-8').encode('cp936')
#给列所有赋值
#df2["date"] = "2017-01-01"

#给固定列和下标位置赋值
cldValue = Series(["2017-01-01"], index=[0, 3])
df2["date"] = cldValue

print df2